In Svelte, {#if} blocks are used to conditionally render parts of your markup. You can also include {:else if} to handle additional conditions and {:else} to provide a default fallback. This works similarly to JavaScript's if, else if, and else statements but is directly written in the component template.
{#if condition} starts the conditional block and renders its content when the condition is true.
{:else if condition} adds another condition to check if the previous one was false.
{:else} defines a default block to render if all previous conditions are false.
The block must be closed with a {/if} statement.
This structure evaluates the conditions in order. The first true condition's block will be rendered, and the others will be ignored.
In this example, Svelte checks the score variable and renders the appropriate grade based on the first condition that evaluates to true.